package com.lh.blogArticle.service.Impl;

import com.lh.blogArticle.entity.FollowFeelingEntity;
import com.lh.blogArticle.entity.LifeGrowthEntity;
import com.lh.blogArticle.mapper.LifeGrowthMapper;
import com.lh.blogArticle.service.LifeGrowthService;
import com.lh.blogCommon.util.PageUtils;
import com.lh.blogCommon.util.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;


@Service("lifeGrowthService")
public class LifeGrowthServiceImpl extends ServiceImpl<LifeGrowthMapper, LifeGrowthEntity> implements LifeGrowthService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<LifeGrowthEntity> queryWrapper = new QueryWrapper<>();

        String key = (String) params.get("key");
        System.out.println(params);
        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("lifegrowth_id",key).or()
                    .eq("content",key).or()
                    .eq("write_time", key);

        }

        queryWrapper.orderByDesc("lifegrowth_id");

        IPage<LifeGrowthEntity> page = this.page(
                new Query<LifeGrowthEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}